******SET YOUR DIRECTORY to ...\replication





clear all


///////////////////////////////////////////////////////////////////////////////////////////
///METRO SAMPLE
///////////////////////////////////////////////////////////////////////////////////////////

set obs 1
gen aaa=.

tempfile t1
save `t1'

forvalues i=74/91{
clear all
import sas METRO SMSA HOWN ISTATU CRIME HDWN SCH SCHOK SCHM ///
		   WEIGHT MOVED RMYEAR XLOC WHYMOV WHYTO using "rawdata\AHS\AHS_19`i'_Metro\ahs`i'msa.sas7bdat"

gen year=19`i'

append using `t1'
save `t1', replace
*codebook
*METRO: 113
*SMSA: 116
*ISTATUS: 128
*HOWN: 174
*CRIME: 176
*SCH, SCHOK, SCHM: 178
*AGE: 195
*GRAD: 198
*WEIGHT: 202
*MOVED: 266
*RMYEAR: 267
*XLOC: 269
*WHYMOVE: 276
}

drop aaa
drop if year==.

replace SMSA=6780 if SMSA==7280
replace SMSA=5720 if SMSA==5680

save rawdata\AHS\data_ahs, replace


///////////////////////////////////////////////////////////////////////////////////////////
///NATIONAL SAMPLE
///////////////////////////////////////////////////////////////////////////////////////////

clear all

set obs 1
gen aaa=.

tempfile t1
save `t1'

foreach i in 74 75 76 77 78 79 80 81 83 85 87 89 91{
clear all
import sas METRO HOWN ISTATU CRIME HDWN SCH SCHOK SCHM ///
		   WEIGHT MOVED RMYEAR XLOC WHYMOV WHYTO using "rawdata\AHS\AHS_19`i'_National\ahs`i'n.sas7bdat"

gen year=19`i'

append using `t1'
save `t1', replace
*codebook
*METRO: 113
*SMSA: 116
*ISTATUS: 128
*HOWN: 174
*CRIME: 176
*SCH, SCHOK, SCHM: 178
*AGE: 195
*GRAD: 198
*WEIGHT: 202
*MOVED: 266
*RMYEAR: 267
*XLOC: 269
*WHYMOVE: 276
}

drop aaa
drop if year==.

save rawdata\AHS\data_ahs_nat, replace
